package com.example.locationgps;


import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConnectionUtil {
   public Connection getConnection() throws IOException, TimeoutException {
       ConnectionFactory factory = new ConnectionFactory();
       //设置服务地址
//       factory.setHost("192.168.0.104");
       factory.setHost("106.14.243.179");
       //端口
       factory.setPort(5672);
       //设置账号信息，用户名、密码、vhost  guest
       factory.setVirtualHost("gpshost");
       factory.setUsername("transgps");
       factory.setPassword("transgps");
       // 通过工程获取连接
       Connection connection = factory.newConnection();
       return connection;
   }
}
